package com.lds.config.center.client.listener;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class DefaultItemChangeEventPublisher implements ItemChangeEventPublisher {
    private final List<ItemChangeEventListener> listeners = new CopyOnWriteArrayList<>();

    @Override
    public void publish(ItemChangeEvent event) {
        for (ItemChangeEventListener listener : listeners) {
            listener.onChange(event);
        }
    }

    @Override
    public void register(ItemChangeEventListener listener) {
        listeners.add(listener);
    }
}
